package com.sys.Entity;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
import javax.xml.bind.annotation.XmlTransient;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnore;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Maps;
import com.sys.utils.Page;
import com.sys.utils.Page2;
import com.sys.utils.StringUtils;
public abstract class DataEntity<T> implements Serializable {
	private static final long serialVersionUID = 1L;
	protected String id;
	protected Date createDate;
	protected Date updateDate;
	protected String createBy;
	protected String updateBy;
	protected String delFlag;
	protected Page<T> page;
	protected Page2 page2;
	protected PageInfo<T> page3;
	protected Map<String, String> sqlMap;
	protected boolean isNewRecord = false;
	public Page2 getPage2() {
		return page2;
	}
	public void setPage2(Page2 page2) {
		this.page2 = page2;
	}
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	public Date getUpdateDate() {
		return updateDate;
	}
	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}
	public String getCreateBy() {
		return createBy;
	}
	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}
	public String getUpdateBy() {
		return updateBy;
	}
	public void setUpdateBy(String updateBy) {
		this.updateBy = updateBy;
	}
	public String getDelFlag() {
		return delFlag;
	}
	public void setDelFlag(String delFlag) {
		this.delFlag = delFlag;
	}
	public void setNewRecord(boolean isNewRecord) {
		this.isNewRecord = isNewRecord;
	}
	@JsonIgnore
	@XmlTransient
	public Page<T> getPage() {
		if (page == null) {
			page = new Page<T>();
		}
		return page;
	}
	public Page<T> setPage(Page<T> page) {
		this.page = page;
		return page;
	}
	@JsonIgnore
	@XmlTransient
	public Page<T> getPage3() {
		if (page == null) {
			page = new Page<T>();
		}
		return page;
	}
	public PageInfo<T> setPage3(PageInfo<T> page) {
		this.page3 = page;
		return page;
	}
	public DataEntity() {

	}
	public DataEntity(String id) {
		this();
		this.id = id;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	@JsonIgnore
	@XmlTransient
	public Map<String, String> getSqlMap() {
		if (sqlMap == null) {
			sqlMap = Maps.newHashMap();
		}
		return sqlMap;
	}
	public void setSqlMap(Map<String, String> sqlMap) {
		this.sqlMap = sqlMap;
	}
	public boolean getIsNewRecord() {
		return isNewRecord || StringUtils.isBlank(getId());
	}
	public void setIsNewRecord(boolean isNewRecord) {
		this.isNewRecord = isNewRecord;
	}
	@Override
	public boolean equals(Object obj) {
		if (null == obj) {
			return false;
		}
		if (this == obj) {
			return true;
		}
		if (!getClass().equals(obj.getClass())) {
			return false;
		}
		DataEntity<?> that = (DataEntity<?>) obj;
		return null == this.getId() ? false : this.getId().equals(that.getId());
	}
	@Override
	public String toString() {
		return ReflectionToStringBuilder.toString(this);
	}
}
